﻿// Decompiled with JetBrains decompiler
// Type: DnProcessSimulateCommands.CApAPPOptimizeLengthCommand
// Assembly: DnProcessSimulateCommands, Version=2402.0.0.890, Culture=neutral, PublicKeyToken=null
// MVID: A885D881-AEDF-447E-852A-6F13102E089C
// Assembly location: C:\Program Files\Tecnomatix_2402\eMPower\DotNetCommands\DnProcessSimulateCommands.dll

using DnProcessSimulateCommands.AutomaticPathPlanner.Planner;
using EngineeringInternalExtension;
using System.Collections.Generic;


namespace DnProcessSimulateCommands;

public class CApAPPOptimizeLengthCommand(
  List<CApAPPTask> i_tasks,
  KiAppPathPlanningParamsEx i_pathPlanningParams) : CApAPPPlanCommand(i_tasks, i_pathPlanningParams, false, false)
{
  internal override CApAPPSegmentPlanCommand DoCreateThreadCommand(
    CApAPPSubTask i_subtask,
    KiAppPathPlanningParamsEx i_pathPlanningParams,
    bool i_optimize)
  {
    return (CApAPPSegmentPlanCommand) new CApAPPSegmentOptimizeLengthCommand(i_subtask, i_pathPlanningParams);
  }

  protected override bool IsPlanned(CApAPPSubTask subtask) => subtask.IsToOptimize();

  protected override List<CApAPPSubTask> GetAllSubtasksToPlan()
  {
    List<CApAPPSubTask> allSubtasksToPlan = new List<CApAPPSubTask>();
    for (int index = 0; index < this.TasksToPlan.Count; ++index)
    {
      for (int i_index = 0; i_index < this.TasksToPlan[index].CountSubTasks(); ++i_index)
      {
        if (this.TasksToPlan[index].SubTask(i_index).IsToOptimize())
          allSubtasksToPlan.Add(this.TasksToPlan[index].SubTask(i_index));
      }
    }
    return allSubtasksToPlan;
  }
}
